home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 9
/
FM Towns Free Software Collection 9.iso
/
t_os
/
tool
/
extdrv
/
src
/
util.asm
< prev
Wrap
Assembly Source File
|
1994-11-16
|
5KB
|
393 lines
_TEXT segment para public 'CODE'
_TEXT ends
_DATA segment dword public 'DATA'
_DATA ends
_BSS segment dword public 'BSS'
_BSS ends
DGROUP group _TEXT,_DATA, _BSS
assume cs:DGROUP
assume ds:DGROUP
_TEXT segment para public 'CODE'
public _get_apl3
_get_apl3 proc near
mov dx,404H
in al,dx
ret
_get_apl3 endp
public _set_apl3
_set_apl3 proc near
push bp
mov bp,sp
mov ax,4[bp]
mov dx,404H
IFNDEF NOAPL3
out dx,al
ENDIF
pop bp
ret
_set_apl3 endp
public _strcpy
_strcpy proc near
push bp
mov bp,sp
push si
push di
mov di,4[bp]
mov si,6[bp]
#1:
mov al,[si]
mov [di],al
inc si
inc di
or al,al
jne #1
pop di
pop si
pop bp
ret
_strcpy endp
public _strlen
_strlen proc near
push bp
mov bp,sp
mov bx,4[bp]
xor ax,ax
jmp #2
#1:
inc bx
inc ax
#2:
cmp byte ptr [bx],0
jne #1
pop bp
ret
_strlen endp
public _strchr
_strchr proc near
push bp
mov bp,sp
mov bx,4[bp]
mov al,6[bp]
jmp #2
#1:
inc bx
#2:
mov ah,[bx]
or ah,ah
je #3
cmp ah,al
jne #1
mov ax,bx
pop bp
ret
#3:
xor ax,ax
pop bp
ret
_strchr endp
public _memcpy
_memcpy proc near
push bp
mov bp,sp
push si
push di
mov ax,ds
mov es,ax
mov di,4[bp]
mov si,6[bp]
mov cx,8[bp]
cld
rep movsb
pop di
pop si
pop bp
ret
_memcpy endp
public _bzero
_bzero proc near
push bp
mov bp,sp
push di
mov di,4[bp]
;
; mov ax,6[bp]
; mov es,ax
; mov cx,8[bp]
mov ax,ds
mov es,ax
mov cx,6[bp]
;
xor eax,eax
shr cx,2
cld
rep stosd
mov cx,6[bp]
and cx,3
je #1
rep stosb
#1:
pop di
pop bp
ret
_bzero endp
public _strcmp
_strcmp proc near
push bp
mov bp,sp
push si
push di
mov ax,1
mov di,4[bp]
mov si,6[bp]
#1:
mov bl,[si]
cmp bl,[di]
jne #2
inc si
inc di
or bl,bl
jne #1
xor ax,ax
#2:
pop di
pop si
pop bp
ret
_strcmp endp
public _strcpy_from
_strcpy_from proc near
push bp
mov bp,sp
push si
push di
mov si,4[bp]
mov ax,6[bp]
mov es,ax
mov di,8[bp]
#1:
mov al,es:[si]
mov [di],al
inc si
inc di
or al,al
jne #1
;
pop di
pop si
pop bp
ret
_strcpy_from endp
public _strcpy_to
_strcpy_to proc near
push bp
mov bp,sp
push si
push di
mov si,4[bp]
mov di,6[bp]
mov ax,8[bp]
mov es,ax
#1:
mov al,[si]
mov es:[di],al
inc si
inc di
or al,al
jne #1
;
pop di
pop si
pop bp
ret
_strcpy_to endp
public _copy_to
_copy_to proc near
push bp
mov bp,sp
push si
push di
mov si,4[bp]
mov cx,6[bp]
mov di,8[bp]
mov ax,10[bp]
mov es,ax
cld
mov bx,cx ; save
shr cx,2
je SHORT #1
rep movsd ; word align is not considered now ^_^;
#1:
mov cx,bx ; restore
and ecx,3 ; rest count
je SHORT #2
rep movsb
#2:
pop di
pop si
pop bp
ret
_copy_to endp
public _copy_from
_copy_from proc near
push bp
mov bp,sp
push ds
push si
push di
mov ax,ds
mov es,ax
mov si,4[bp]
mov ax,6[bp]
mov ds,ax
mov cx,8[bp]
mov di,10[bp]
cld
mov bx,cx ; save
shr cx,2
je SHORT #1
rep movsd ; word align is not considered now ^_^;
#1:
mov cx,bx ; restore
and cx,3 ; rest count
je SHORT #2
rep movsb
#2:
pop di
pop si
pop ds
pop bp
ret
_copy_from endp
extrn org_ss:word, org_sp:word, _regs:near
public _set_owner
_set_owner proc near
push bp
mov bp,sp
push es
push di
mov di,4[bp]
mov ax,6[bp]
mov es,ax
mov cx,sp
mov ss,cs:org_ss
mov sp,cs:org_sp
push ds
mov ds,word ptr ds:_regs+20
mov ax,120cH ; set filetbl owner
int 2fH
pop ds
mov ax,ds
mov ss,ax
mov sp,cx
pop di
pop es
pop bp
ret
_set_owner endp
public _get_param
_get_param proc near
push bp
mov bp,sp
push es
mov ax,cs:org_ss
mov es,ax
mov bx,cs:org_sp
mov ax,es:6[bx]
pop es
pop bp
ret
_get_param endp
public _xcopy
_xcopy proc near
push bp
mov bp,sp
push si
push di
mov si,4[bp]
mov bx,6[bp]
mov di,8[bp]
mov dx,10[bp]
mov cx,12[bp]
mov ah,23H
int 8eH
pop di
pop si
IFNDEF NOAPL3
mov dx,404H
in al,dx
or al,80H
out dx,al
ENDIF
pop bp
ret
_xcopy endp
public _xalloc
_xalloc proc near
push bp
mov bp,sp
push di
IFNDEF NOAPL3
mov dx,404H
in al,dx
push ax
and al,7fH
out dx,al
ENDIF
mov cx,4[bp] ; size in KB
mov ah,21H ; alloc protect memory
int 8eH ; dx:di <-- start address
jnc #1
xor dx,dx
xor di,di
#1:
IFNDEF NOAPL3
pop ax
mov bx,dx ; save dx
mov dx,404H
out dx,al
mov dx,bx ; restore dx
ENDIF
mov ax,di
pop di
pop bp
ret
_xalloc endp
public _xfree
_xfree proc near
push bp
mov bp,sp
push di
mov di,4[bp]
mov dx,6[bp]
or dx,dx
jne #1
or di,di
je #2
#1:
mov ah,22H ; free protect memory
int 8eH
#2:
pop di
pop bp
ret
_xfree endp
_TEXT ends
end